package dba.example.guice.dao.impl

import com.google.inject.persist.Transactional
import dba.example.entities.Company
import dba.example.guice.dao.CompanyDao
import dba.example.guice.finders.CompanyFinder
import javax.inject.Inject
import javax.persistence.EntityManager
import dba.example.guice.dao.AccountDao
import dba.example.guice.finders.AccountFinder
import dba.example.entities.Account

class AccountDaoImpl @Inject() (val em: EntityManager, val af: AccountFinder) extends AccountDao {

  override def findAll() = af.findAll()

  override def get(id: Integer): Account = em.find(classOf[Account], id)

  @Transactional
  override def save(account: Account) = em.merge(account)

  @Transactional
  override def remove(account: Account): Unit = em.remove(account)

}